package com.imooc.spark

import java.sql.DriverManager

/**
  * 通过JDBC方式访问
  */
object SparkSQLThriftServerApp {
  def main(args: Array[String]): Unit = {

    Class.forName("org.apache.hive.jdbc.HiveDriver")

    val conn = DriverManager.getConnection("jdbc:hive2://192.168.11.161:10000","hadoop","")
    val pstmt = conn.prepareStatement("select * from student")
    val rs = pstmt.executeQuery()
    while(rs.next()){
      println("Id:"+rs.getInt("id")+"; name:"+rs.getString("name"))
    }
    rs.close()
    pstmt.close()
    conn.close()
  }
}
